/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package infoplaces2;

import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author andre
 */
class CircularList {

    private int[] conteudo;

    CircularList(int[] conteudo) {
        this.conteudo = conteudo;
    }

    public int get(int index) { // para um index negativo nao funciona direito
        int i;
        if (index > conteudo.length - 1) {
            i = (index) % conteudo.length;
            System.out.println("i = " + i);
        } else {
            if (index < 0) {
                i = conteudo.length + index;
            } else {
                i = index;
            }
        }
        return conteudo[i];
    }

    public int size() {
        return conteudo.length;
    }
    public void print(){
        for (int i = 0; i < conteudo.length; i++) {
            System.out.println("vetor[" + i + "] = " + conteudo[i]);
        }
        System.out.println("");
    }
}
